const patternList = [
  { label: "全局搜索", value: "g" },
  { label: "不区分大小写搜索", value: "i" },
  { label: "多行搜索", value: "m" },
  { label: "允许.匹配换行符", value: "s" },
  { label: "使用 unicode 码的模式进行匹配", value: "u" },
  { label: "粘性搜索, 匹配从目标字符串的当前位置开始", value: "y" }
];

type descriptType = {
  code: string; // 示例代码
  descript: string; // 描述
};

type btnsType = {
  title: string;
  descriptList: Array<descriptType>;
};

// 语法数据
const descriptList: Array<btnsType> = [
  {
    title: "方括号",
    descriptList: [
      { code: "[a|b]", descript: "a或b" },
      { code: "[a-z]", descript: "任意小写字母" },
      { code: "[A-Z]", descript: "任意大写字母" },
      { code: "[0-9]", descript: "任意数字" },
      { code: "[0-9a-zA-Z]", descript: "任意数字大小写字母" },
      { code: "[^x]", descript: "除了x (内部取反的意思)" },
      { code: "^[abc]$", descript: "多选一" }
    ]
  },
  {
    title: "量词参考",
    descriptList: [
      { code: "{n}", descript: "正好出现 n次" },
      { code: "{n,m}", descript: "出现 n~m次" },
      { code: "{n,}", descript: "出现 n次 或 n次以上" },
      { code: "+", descript: "至少一个, 相当于 {1,}" },
      { code: "*", descript: "0个或多个, 相当于 {0,}" },
      { code: "?", descript: "0个或1个, 相当于 {0,1}, (可用于禁止贪婪)" }
    ]
  },
  {
    title: "边界符",
    descriptList: [
      { code: "^", descript: "表示开头(^写到方括号里是除了的意思)" },
      { code: "$", descript: "表示结尾" }
    ]
  },
  {
    title: "元字符",
    descriptList: [
      { code: ".", descript: "表示除换行符以外的任意字符" },
      { code: "\\.", descript: "表示 ." },
      { code: "\\\\", descript: "表示 \\" },
      { code: "\\w", descript: "任意字母, 数字, [A-z0-9_]" },
      { code: "\\W", descript: "除了字母, 数字, [^A-z0-9_]" },
      { code: "\\d", descript: "任意的数字 [0-9]" },
      { code: "\\D", descript: "除了数字 [^0-9]" },
      { code: "\\s", descript: "空格" },
      { code: "\\S", descript: "除了空格" },
      { code: "\\b", descript: "单词边界" },
      { code: "\\B", descript: "除了单词边界" }
    ]
  },
  {
    title: "分组, 引用和变量",
    descriptList: [
      { code: "()", descript: "把括号里的当成一个分组,可以被\\n引用" },
      { code: "\\n", descript: "引用第n个分组的的表达式" },
      { code: "$n", descript: "在替换时使用匹配的组数据" }
    ]
  },
  {
    title: "命名捕获分组",
    descriptList: [{ code: "(?<分组名>xxx)", descript: "将xxx匹配到的文本存储到 .groups.分组名 变量中" }]
  },
  {
    title: "正向断言",
    descriptList: [
      { code: "yyy(?=xxx)", descript: "表示 ?= 后面的 `是` xxx 并且满足 yyy 才算匹配条件" },
      { code: "yyy(?!xxx)", descript: "表示 ?! 后面的 `不是` xxx 并且满足 yyy 才算匹配条件" }
    ]
  },
  {
    title: "反向断言",
    descriptList: [
      { code: "(?<=xxx)yyy", descript: "表示 ?<= 前面的 `是` xxx 并且满足 yyy 才算匹配条件" },
      { code: "(?<!xxx)yyy", descript: "表示 ?<! 前面的 `不是` xxx 并且满足 yyy 才算匹配条件" }
    ]
  },
  {
    title: "dotAll模式",
    descriptList: [
      {
        code: "/(.*?)/s",
        descript: "元字符. 默认可以匹配除换行符以外的任意单个字符, 添加 s 修饰符元字符后, .将可以匹配任意字符包括换行"
      }
    ]
  }
];

// 示例
const exampleList: Array<btnsType> = [
  {
    title: "校验数字",
    descriptList: [
      { code: "^\\d*$", descript: "数字" },
      { code: "^\\d{n}$", descript: "n位数字" },
      { code: "^\\d{n,}$", descript: "至少n位数字" },
      { code: "^\\d{m,n}$", descript: "m~n位数字" }
    ]
  },
  {
    title: "校验字符",
    descriptList: [{ code: "^[\\u4e00-\\u9fa5]{0,}$", descript: "汉字" }]
  },
  {
    title: "特殊校验",
    descriptList: [
      { code: "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)", descript: "身份证" },
      { code: "/<(?<tag>.*?)>\\s*(?<content>.*?)\\s*<\\/.*?\\s*>/s", descript: "匹配HTML" }
    ]
  },
  {
    title: "TODO",
    descriptList: []
  }
];

export { descriptList, patternList, exampleList };
